home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12985 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: unixg.ubc.ca!news
  2. From: jamesdf@unixg.ubc.ca (James Fairweather)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Can anyone HELP with variable delaration? Please?
  5. Date: Wed, 03 Apr 1996 20:44:57 GMT
  6. Organization: University of British Columbia
  7. Message-ID: <3162de71.18703379@news.ucs.ubc.ca>
  8. References: <4jt07b$dul@news.us.net> <3162119a.43634755@news.ucs.ubc.ca> <4juf2kINNe9v@keats.ugrad.cs.ubc.ca>
  9. NNTP-Posting-Host: srtb0411a01.resnet.ubc.ca
  10. X-Newsreader: Forte Agent .99d/32.182
  11.  
  12. >Any variable can be declared constant, including strings:
  13. >
  14. >    const char * const str = "Foo";
  15. >
  16. >Or do you mean literal constants?
  17. >
  18. I'm not sure what the difference is.  I thought the keyword "const"
  19. was just for the compiler.  If you tried to modify the variable
  20. declared const, the compiler would complain.  Does it do something
  21. else with the variable if you declare it const?
  22.  
  23. >In what way are integers a suitable alternative representation for string data?
  24. >-- 
  25. I guess I was being too extreme.  It's just that in high school, when
  26. we were coding with Pascal, we were encouraged to use strings
  27. whereever possible.  Don't ask me why; it never occurred to me to ask
  28. at the time.  And sometimes when I read other people's code,
  29. espeically people who are used to Pascal, I often see them using
  30. strings in an if...else situation.  In these cases, a well-name
  31. #defined constant works better, because you can use switch and the
  32. comparison is faster.
  33. ---
  34. James Fairweather
  35. 4th year Comp. Eng, UBC
  36. Vancouver, BC, Canada
  37. jamesdf@unixg.ubc.ca
  38. 604.228.2269
  39.